<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\AdminBuilder;
use Encore\Admin\Traits\ModelTree;
use App\Models\Class_type;
use App\Models\Test_config;
use App\Models\Test_report;
use App\Models\Student_test_score;
use App\Models\Apply;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Squad extends Model
{
	public $timestamps = false;
    //
    protected $fillable = [
        'name','full_name','type', 'section', 'group','no', 'start_year','start_season','start_date','end_date', 'campus','class_teacher', 'batch',
    ];

    public function students()
    {
        return $this->hasMany(Student::class);
    }

    public function classtype()
    {
        return $this->hasOne(Class_type::class,'id','type');
    }

    public function test_report()
    {
        return $this->hasMany(Test_report::class);
    }

    public function classsection()
    {
        return $this->hasOne(Class_section_group::class,'id','section');
    }

    public function classgroup()
    {
        return $this->hasOne(Class_section_group::class,'id','group');
    }

    public function credits_squad()
    {
        return $this->hasOne(Credits_squad::class);
    }

    public function Squad_month()
    {
        return $this->hasOne(Squad_month::class);
    }

    public function test_configs() : BelongsToMany
    {
        return $this->belongsToMany(Test_config::class, 'test_assigns', 'squad_id', 'test_config_id');
    }

    public function apply()
    {
        return $this->hasMany(Apply::class);
    }

    public function Squad_crouse()
    {
        return $this->hasMany(Squad_crouse::class,'squad_id');
    }
}
